<?php
session_start();
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";

if ($_REQUEST["hidId"] <> "") {
    $tabla = "solotb_parametros";

    switch ($_REQUEST["Opcion"]) {
        case 1:
            $tipo = "UPDATE";
            $strSql = "$tipo $tabla set ";
            $strSql .= "descripcion='" . $_REQUEST["TxtDesc"] . "', ";
            $strSql .= "valor='" . $_REQUEST["TxtDesc2"] . "' ";
            $strSql .= "where id=" . $_REQUEST["hidId"];
            $strSql .= " and nodo=" . $_REQUEST["hidNodo"];

            $Parametros = "&id=" . $_REQUEST["hidId"] . "&Opcion=" . $_REQUEST["Opcion"] . "&ds=" . $_REQUEST["TxtDesc"] . "&valor=".$_REQUEST["TxtDesc2"] . "&CboNodo=" . $_REQUEST["hidNodo"];
            break;
        case 2:
            $tipo = "DELETE";
            $strSql = "$tipo from $tabla where id=" . $_REQUEST["hidId"];

            //'Parametros= "&id=" & $_REQUEST["hidId") & "&Opcion=" & $_REQUEST["Opcion") & "&ds=" & $_REQUEST["TxtDesc") & "&valor="&$_REQUEST["TxtDesc2") & "&CboNodo=" & $_REQUEST["hidNodo")
            $Parametros =  "&Opcion=" . $_REQUEST["Opcion"] . "&CboNodo=" . $_REQUEST["hidNodo"];
            break;
        case 3:
            $tipo = "INSERT";
            $strSql = "$tipo into $tabla values (";
            $strSql .=  $_REQUEST["hidId"] . ",";
            $strSql .=  $_REQUEST["hidNodo"] . ",'";
            $strSql .=  $_REQUEST["TxtDesc"] . "','";
            $strSql .=  $_REQUEST["TxtDesc2"] . "')";

            $Parametros = "&id=" . $_REQUEST["hidId"] . "&Opcion=" . $_REQUEST["Opcion"] . "&ds=" . $_REQUEST["TxtDesc"] . "&valor=" . $_REQUEST["TxtDesc2"] . "&CboNodo=" . $_REQUEST["hidNodo"];
            break;
    }

    $arrQueries = array();
    array_push($arrQueries, $strSql);
    array_push($arrQueries, crearQueryLog($tabla, $tipo, $strSql));
    $oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
            $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
    //if(!$oConexion->EjecutarQuery($strSql)) {
    if(!$oConexion->EjecutarTransaccion($arrQueries)) {
        //'response.write STRsqL & err.description
        $strMsg = "solotrn_Grabarparametro.php?SoloError=1";
    }else {
        $strMsg = "solotrn_Grabarparametro.php?SoloError=0" . $Parametros;
    }
    $oConexion->Cerrar();
    //'response.write  strMsg
    //'re
    header ($strMsg);
}

switch ($_REQUEST["Opcion"]) {
    case 1:
        $imagen = "iconos/soloico_grabar.gif";
        $etiqueta = "Modificar Par&aacute;metro";
        $oculto = "<input type='hidden' name='Opcion' value=1>";
        $titulo = "Modificar Par&aacute;metros";
        break;
    case 2:
        $imagen = "iconos/soloico_eliminar.gif";
        $etiqueta = "Eliminar Par&aacute;metros";
        $oculto = "<input type='hidden' name='Opcion' value=2>";
        $titulo = "Eliminar Par&aacute;metros";
        break;
    case 3:
        $imagen = "iconos/soloico_grabar.gif";
        $etiqueta = "Ingresar Par&aacute;metros";
        $oculto = "<input type='hidden' name='Opcion' value=3>";
        $titulo = "Ingresar Par&aacute;metros";
        break;
}

?>
<html>
    <head>
        <title>SoloPortal - Par&aacute;metros</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="SoloStyles/Solostyles.css" rel="stylesheet" type="text/css">
    </head>

    <body topmargin=0 leftmargin=0>
        <img src="templates/SoloTemplate_LogoCabecera.png" style="height: 50px"/>

        <p align="center" class="SoloStyle_TituloPaginas"><?php echo $Titulo;?></p>

        <?php if ($_REQUEST["opc"] <> "C") {?>
        <form name="frmIngreso" action="solotrn_GrabarParametro.php" method="POST">
            <center>
                <table border="0" width="80%" align="center" cellpadding="2" cellspacing="1" bordercolor="#CCCCCC">
                    <tr>
                        <td> <img src="<?php echo $imagen;?>" border="1" alt="<?php echo $etiqueta;?>" style="cursor:hand" onClick="frmIngreso.submit();">
                            <img src="iconos/soloico_salir.gif" border="1" alt="Regresar" style="cursor:hand" onClick="window.opener.location.reload();window.close();" >
                        </td>
                </table>
                <table border="0" width="80%" bordercolor="#CCCCCC" cellpadding="2" cellspacing="2">
                    <tr>
                        <td width="20%" class="SoloStyle_Etiqueta"><b>Id</b></td>
                        <td width="80%" class="SoloStyle_EtiquetaCajas"><?php echo $_REQUEST["id"];?>
                            <input type="hidden" maxlenght="50" size="8" name="hidNodo" class="texto" value="<?php echo $_REQUEST["CboNodo"];?>">
                            <input type="hidden" maxlenght="50" size="50" name="hidId" class="texto" value="<?php echo $_REQUEST["id"];?>"></td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta"><b>Descripci&oacute;n</b></td>
                        <td class="SoloStyle_EtiquetaCajas">
                            <input type="text" maxlenght="50" size="50" name="TxtDesc" class="SoloStyle_Texto" value="<?php echo $_REQUEST["ds"];?>"></td>
                    </tr>
                    <tr>
                        <td class="SoloStyle_Etiqueta"><b>Valor</b></td>
                        <td class="SoloStyle_EtiquetaCajas">
                            <input type="text" maxlenght="50" size="50" name="TxtDesc2" class="SoloStyle_Texto" value="<?php echo $_REQUEST["valor"];?>"></td>
                    </tr>
                </table>
            </center>
            <br><center><?php echo $BOTON;?><?php echo $oculto;?></center>
        </form>
        <br>
            <?php }else {?>
        <table width="75%" border="0" align="center" class="grid">
            <tr class="etiqueta">
                <td>M&oacute;dulo: <?php echo $_REQUEST["ds"];?></td>
            </tr>
                <?php if ($bandPar) {
                    for ($i = 0; $i < count($arrData); $i++) {?>
            <tr>
                <td><?php echo $arrData[$i][2];?></td>
            </tr>
                        <?php 	}
                }
                ?>
        </table>
        <br><center><?php echo $BOTON;?></center>
            <?php }

        ?>

    </body>
</html>
<!-- #include file="Includes/solofun_showmessages.asp"-->